<?php
// Author: dolphinigle
// 28 March 2012
include 'config/koneksi.php';

if ($_GET[type] == 'likes') {
  $query = "SELECT COUNT(id_likes) AS cnt FROM likes " .
           "WHERE id_berita='" . $_GET[id] . "' AND " .
           "username='" . $_GET[username] . "'";
} elseif ($_GET[type] == 'dislike') {
  $query = "SELECT COUNT(id_dislike) AS cnt FROM dislike " .
           "WHERE id_berita='" . $_GET[id] . "' AND " .
           "username='" . $_GET[username] . "'";
} else {
  exit('UNRECOGNIZED TYPE PARAMETER');
}

$sql_answer = mysql_query($query);
$ans = mysql_fetch_array($sql_answer);

if ($ans[cnt] > 0) {
  echo "YES";
} else {
  echo "NO";
}
?>
